import {
  ArticlePageParam,
  TagPageParam,
  TagAddParam,
  TagUpdatedParam,
  CategoryPageParam,
  CategoryAddParam,
  CategoryUpdatedParam,
  ArticleListGetResultModel,
  TagPageListGetResultModel,
  CategoryPageListGetResultModel,
} from './model/blogModel';
import { defHttp } from '/@/utils/http/axios';

enum Api {
  article = '/plugins/baliServer-module-blog/api/blog/article',
  tag = '/plugins/baliServer-module-blog/api/blog/tag',
  category = '/plugins/baliServer-module-blog/api/blog/category',
}

/**
 * 博文
 */
  export const getPostList = (params: ArticlePageParam) =>
  defHttp.get<ArticleListGetResultModel>({ url: Api.article+'/list', params }, { isPage: true });
  export const deletePost = (params?: {id:string}) => defHttp.post({ url: Api.article+'/remove', params });
  export const setPostStatus = (params?:{id:string,status:number}) => defHttp.post({ url: Api.article + '/updateStatus' , params});

/**
 * 标签
 */
 export const addTag = (params?: TagAddParam) => defHttp.post({ url: Api.tag+'/add', params });
 export const getTagList = (params: TagPageParam) =>
 defHttp.get<TagPageListGetResultModel>({ url: Api.tag+'/list', params }, { isPage: true });
 export const editTag = (params?: TagUpdatedParam & TagAddParam) =>
 defHttp.post({ url: Api.tag+'/edit', params });
 export const deleteTag = (params?: {id:number}) => defHttp.post({ url: Api.tag+'/delete', params });

/**
 * 种类
 */
 export const addCategory = (params?: CategoryAddParam) => defHttp.post({ url: Api.category+'/add', params });
 export const getCategoryList = (params: CategoryPageParam) =>
 defHttp.get<CategoryPageListGetResultModel>({ url: Api.category+'/list', params }, { isPage: true });
 export const editCategory = (params?: CategoryUpdatedParam & CategoryAddParam) =>
 defHttp.post({ url: Api.category+'/edit', params });
 export const deleteCategory = (params?: {id:number}) => defHttp.post({ url: Api.category+'/delete', params });
